<template>
	<view class="">
		<scroll-view scroll-x='true' class="myNav">
			<view class="item" style='font-size: 30rpx;' v-for="(item,index) in leftArray"
				:class="active==index?'active':'' " @tap="leftTap(item,index)">{{item}}</view>
		</scroll-view>
		<view class="timeBottom">
			<view class="timeItem" v-for="(timeItem,timeIndex) in timesList" :key="timeIndex"
				:class="show==timeIndex?'show':'no'">
				<view class="time" v-for="(item,index) in timeItem.data" :key="index">
					<view class="img">
						<image :src="item.timesUrl"></image>
					</view>
					<view class="ming">
						<text class="timeText3">{{item.timeText3}}</text>
					</view>
					<view class="timeText">
						<text class="timeText1">￥{{item.price}}</text>
						<text class="timeText2">￥{{item.oldprice}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	export default {
		data() {
			return {
				leftArray: ['推荐', '箱包', '男装', '女装', '鞋子', '裤子', '汽车', '食品', '维修', '机票', '安装', '图书', '宠物'],
				show: 0,
				active: 0
			}

		},
		computed: {
			...mapState([
				'timesList'
			])
		},
		methods:{
		leftTap(item,index) {
			this.active=index
			this.show=index
		},	
		}
	}
</script>

<style lang='scss' scoped>
	.myNav {
		white-space: nowrap;
		display: flex;
		color: #333;
		box-sizing: border-box;
		height: 80rpx;

		.item {
			flex: 1;
			margin: 10rpx 20rpx;
			display: inline-block;

			&.active {
				color: #ff5555;
				border-bottom: 2px solid #ff5555;
			}
		}

		/* 
		.item:hover {
			display: inline-block;
			color: #ff5555;
			border-bottom: 2px solid #ff5555;
		} */
	}

	.timeBottom {
		position: relative;
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;

		.timeItem.no {
			display: none;
		}

		.timeItem.show {
			display: block;
			display: flex;
			justify-content: space-around;
			flex-wrap: wrap;
			padding-bottom: 50px;
			background-color: #f5f5f5a8;
		}

		.timeItem {
			position: absolute;
			/* width: 40%; */
			justify-content: space-around;
			display: flex;
			flex-wrap: wrap;
			/* flex-direction: column; */
			align-items: center;
			/* border: 1px solid #c3c0ca; */
			box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;

			margin-top: 10rpx;

			.time {
				text-align: center;
				margin-top: 15px;
				width: 40%;
				padding: 15px 4px;
				/* border: 1px solid #9F9F9Fa8; */
				border-radius: 5px;
				background-color: white;
				.img{
					width: 100%;
					height: 140px;
					margin: 0 auto;
				}
			}

			image {
				width: 100%;
				height:100%;
			}

			.ming {
				/* margin-top: 10px; */
				text-align: center;
				margin: 12px auto;
				/* height: 20px; */
				width: 136px;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}

			.timeText {
				display: flex;
				justify-content: space-between;
				font-size: 14px;

				.timeText2 {
					color: #9F9F9F;
					text-decoration: line-through;
				}
			}
		}
	}
</style>